﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;
using Pixysoft.Framework.Configurations;

namespace Pixysoft.Framework.Logs.Core
{
    class Document : IDocument
    {
        IXmlTree tree;

        string filepath = null;

        string filename = null;

        string postfix = null;

        public Document(string filepath, string filename, string postfix)
        {
            tree = XmlManager.CreateTree();

            this.filepath = filepath;
            this.filename = filename;
            this.postfix = postfix;
        }

        public string Filepath
        {
            get
            {
                return filepath;
            }
            set { filepath = value; }
        }

        public string Filename
        {
            get
            {
                return filename;
            }
            set { filename = value; }
        }

        public string Postfix
        {
            get
            {
                return postfix;
            }
            set { postfix = value; }
        }

        public IRecordCollection Records
        {
            get
            {
                return new RecordCollection(tree.Nodes);
            }
        }

        public string Serialize()
        {
            return Serialize(false);
        }

        public string Serialize(bool indent)
        {
            return tree.SerializeAll(indent);
        }
    }
}
